<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('终端按月统计列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">服务商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">服务商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label style="width: 100px;">商户编号：</label>
                                <input type="text" name="merNo"/>
                            </li>
                            <li>
                                <label style="width: 100px;">SN编号：</label>
                                <input type="text" name="sn"/>
                            </li>
                            <li>
                                <label style="width: 100px;">卡类型：</label>
                                <select name="cardType">
                                    <option value="2">贷记卡</option>
                                    <option value="1">借记卡</option>
                                    <option value="3">预付费卡</option>
                                    <option value="0">未知</option>
                                    <option value="">所有</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">添加日期：</label>
                                <input type="text" readonly class="time-input"  placeholder="开始时间" name="start"/>
                                <span>-</span>
                                <input type="text" readonly class="time-input" id="endTime" placeholder="结束时间" name="end"/>
                            </li>
                            <li>
                                <label style="width: 10px;"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 search-collapse">
                <span style="color: blue;font-style: initial">交易总额：</span>
                <span id="sumMoney" style="color: red;font-style: initial">0.00</span><span style="color: blue;font-style: initial"> 元</span>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="SnCountData:SnCountData:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('SnCountData:SnCountData:edit')}]];
        var removeFlag = [[${@permission.hasPermi('SnCountData:SnCountData:remove')}]];
        var prefix = ctx + "statistical/SnCountData";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "终端按月统计",
                responseHandler:responseHandler,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'merNo',
                    title: '商户编号'
                },
                {
                    field: 'sn',
                    title: 'SN编号'
                },
                {
                    field: 'cardType',
                    title: '卡类型',
                    formatter: function (value, row, index) {
                        if ("0" == value) {
                            return '<span style="color:blue;">未知</span>';
                        } else if ("1" == value) {
                            return '<span style="color:green;">借记卡</span>';
                        } else if ("2" == value) {
                            return '<span style="color:blue;">贷记卡</span>';
                        } else if ("3" == value) {
                            return '<span style="color:red;">预付费卡</span>';
                        }
                    }
                },
                {
                    field: 'amount',
                    title: '终端交易总额'
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商名称'
                },
                {
                    field: 'belongAgentNum',
                    title: '所属资深总监编号'
                },
                {
                    field: 'belongAgentName',
                    title: '所属资深总监名称'
                },
                {
                    field: 'addDate',
                    title: '添加日期'
                },
                ]
            };
            $.table.init(options);
        });

        function responseHandler(res) {
            const data = res.data;
            if ($.common.isNotEmpty(data)){
                $("#sumMoney").text(data.amount);
            } else {
                $("#sumMoney").text('0.00');
            }
        }

    </script>
</body>
</html>